package weiyao.xinxidasai.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import weiyao.xinxidasai.DTO.FileTreeNode;
import weiyao.xinxidasai.DTO.Result;
import weiyao.xinxidasai.Utils.ThreadLocal.UserHolder;
import weiyao.xinxidasai.service.FileSystemService;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@RestController
@RequestMapping("/filesystem")
public class FileSystemController {

    @Autowired
    private FileSystemService fileSystemService;

    @GetMapping("/tree")
    public Result getFileTree() {
        Long userId = UserHolder.getUser().getUserId();
        FileTreeNode fileTree = fileSystemService.getUserFileTree(userId);
        return Result.ok(fileTree);
    }
}